package com.example.carefree_server.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//统一响应结果
@NoArgsConstructor//无参构造方法
@AllArgsConstructor//全参构造方法
@Data
public class Result<T> {
    private Integer code;//业务状态码  0-成功  1-失败  ||登录模块 1 - 2 -3对应3个用户
    private String message;//提示信息
    private T data;//响应数据


    //快速返回操作成功响应结果(带响应数据)
    public static <E> Result<E> success(E data) {
        return new Result<>(0, "操作成功", data);
    }

    //快速返回操作成功响应结果
    public static Result success() {
        return new Result(0, "操作成功", null);
    }

    public static Result losuccess(int code,String data){
        return new Result(code,"登录成功",data);
    }

    //信息管理操作
    public static Result addSuccess(){
        return new Result(0,"信息添加成功！",null);
    }
    public static Result UpdateSuccess(){
        return new Result(0,"信息修改成功！",null);
    }
    public static Result deleteSuccess(){
        return new Result(0,"信息已删除！",null);
    }


    public static Result error(String message) {
        return new Result(1, message, null);
    }


    //密保/密码
    public static Result checksuccess(int code,String data){
        return new Result(code,"检验成功",data);
    }
    public static Result changepasswordsuccess(int code,String data){
        return new Result(code,"改密码成功",data);
    }

    public static Result changepasswordprotectionsuccess(int code,String data){
        return new Result(code,"改密保成功",data);
    }

}
